# Takes a set of M' orthonormal eigenvectors, and a vector
# Returns an M' dimensional vector representing the coordinates 
# of the projection of the vector onto the eigenspace spanned by "eigenvectors"
# Params:
#   eigenvectors - a list (see ?list) of M' eigenvectors of the covariance matrix
#   vector - the vector we want to project to the eigenspace
project <- function(eigenvectors, vector){
  M_prime = length(eigenvectors)
  Omega = rep(0, M_prime)
  
  for (i in 1:M_prime){
    Omega[i] = sum(eigenvectors[[i]] * vector)
  }
  
  return (Omega)
}

#####################
# Test cases
#####################
E_1 = list(c(1,0), c(0,1))
v_1 = c(3,4)
print("Expected: c(3,4)")
o_1 = project(E_1, v_1)
print("Actual:")
print(o_1)

E_2 = list(c(3/5,4/5), c(-4/5,3/5))
v_2 = c(5,10)
print("Expected: c(11,2)")
o_2 = project(E_2, v_2)
print("Actual:")
print(o_2)